﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class aspx_admin_hdly_edit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        FileUpload fuxiao = this.FormView1.FindControl("FileUpload1") as FileUpload;
        if (fuxiao.HasFile)
        {
            try
            {
                Guid id = Guid.NewGuid();
                string filename = id.ToString() + System.IO.Path.GetExtension(fuxiao.FileName);
                WebHelper.WebControls.UploadFile(
                         fuxiao,
                         "~/images/hdly/small/",
                         new string[] { ".jpg", ".bmp" },
                         filename,
                         false,
                         int.MaxValue);
                e.NewValues["小图片"] = string.Format("~/images/hdly/small/{0}", filename);
                ImageCroper.ChangeWidthAndHeight(e.NewValues["小图片"] as string, 182, 121);
                WebHelper.FileAndDirectory.DeleteFile(e.OldValues["小图片"] as string);
            }
            catch (Exception)
            {
                e.Cancel = true;
                throw;
            }
        }
       
        
    }
    protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName == "Cancel")
        {
            Response.Redirect("view.aspx");
        }
    }
    protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
    {
        WebHelper.MessageBox.Show("更新成功！", "view.aspx");
    }
}